#ifdef	_WIN32
#include		"MutexWin.hpp"

bool			MutexWin::create(myMutex *var)
{
	bool				ret = true;

	*var = CreateMutex(NULL, FALSE, NULL);
	if (var == NULL)
		ret = false;
	return (ret);
}

void			MutexWin::destroy(myMutex *var)
{
	CloseHandle(*var);
	return ;
}
bool			MutexWin::lock(myMutex *var)
{
	bool				ret = true;
	DWORD			wait;

	wait = WaitForSingleObject(*var, INFINITE);
	if (wait != WAIT_OBJECT_0)
		ret = false;
	return (ret);
}
bool			MutexWin::tryLock(myMutex *var)
{
	bool				ret = true;
	DWORD			wait;

	wait = WaitForSingleObject(*var, INFINITE);
	if (wait != WAIT_OBJECT_0)
		ret = false;
	return (ret);
}

bool			MutexWin::unlock(myMutex *var)
{
	bool				ret = true;
	
	ret = ReleaseMutex(*var);
	return (ret);
}
#endif /*_WIN32*/
